<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.cinema.data.FilmInfo, com.cinema.data.Schedule, java.util.Date, com.cinema.data.Ticket" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Do An Mon Hoc</title>

<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
@import "/css/gallery.css";
</style>

<script type="text/javascript">
var i = 0;
function changeIt(imgno, max) 
{
	var theImg = document.getElementsByTagName('img')[imgno].src;

	var x = theImg.split("/");
	var t = x.length-1;
	var y = x[t];

	if(y=='seat_0.gif')
	{
		if(i < max){
			document.getElementsByTagName('img')[imgno].src = 'images/seat_5.gif';
			document.forms[0].seat[i].value = imgno;
			i = i + 1;
		}
	}
	if(y=='seat_5.gif')
	{
		if(i >=1){
			document.getElementsByTagName('img')[imgno].src = 'images/seat_0.gif';
			i = i - 1;
			document.forms[0].seat[i].value = 0;
		}
	}
}
</script>

</head>
<body>
<div id="container">
	<div id="banner">
	<embed src="http://iss2011.googlecode.com/hg/war/images/BANNER.swf" quality="high" type="application/x-shockwave-flash" wmode="transparent" 
	width="960" height="271" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always"></embed>
	</div>	
	
	<!-- end #banner -->
	<div id="menu">
		<div id="navbar" align="center">
			<ul id="nav">
				<li class="top"><a href="index.jsp" class="top_link"><span>TRANG CHỦ</span></a></li>
				<li class="top"><a href="currentFilm" class="top_link"><span>ĐẶT VÉ</span></a></li>
				<li class="top"><a href="#" class="top_link"><span class="down">PHIM</span></a>
					<ul class="sub">
						<li><a href="currentFilm">Đang Chiếu</a></li>
						<li><a href="comingSoon">Sắp chiếu</a></li>						
					</ul>
				<li class="top"><a href="KhuyenMai.html" class="top_link"><span>KHUYẾN MÃI</span></a></li>
				<li class="top"><a href="FAQ.html" class="top_link"><span>F.A.Q</span></a></li>
			</ul> <!-- End NAV-->
		</div> <!--End NavBar-->
	</div>
	<!-- end #menu -->
<%
	FilmInfo film = (FilmInfo)session.getAttribute("film");
	Ticket t = (Ticket)session.getAttribute("ticket");
	int pos = (Integer)session.getAttribute("selectdate");
	Schedule sched = film.getSchedule();
	boolean[] seat = sched.getSeat(pos);
	int qty = Integer.parseInt(request.getParameter("qty"));
	int tickettype = Integer.parseInt(request.getParameter("tickettype"));
	session.setAttribute("tickettype", tickettype);
%>
	<div id="page-content">
		<div class="page-right">
			<p style="font-size:30px; color:red;">BƯỚC 3: Chọn ghế</p>
<%
	int no = 0;
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 10; j++){
			if(seat[no]){
%>
				<img onclick="changeIt(<%=no %>, <%=qty %>)" src='images/seat_1.gif' name='example' border='0' />
<%
			}else{
%>
				<img onclick="changeIt(<%=no %>, <%=qty %>)" src='images/seat_0.gif' name='example' border='0' />
<%
			}
			no++;
		}
%>
				<br />
<%
	}
%>
			<form action="booking4" method="post">
<%
	for(int i = 0; i < qty; i++){
%>
				<input type="hidden" name="seat" id="<%=i %>" value="0"/>
<%
	}
%>							
			<input type="submit" value="Next" />
			</form>
		</div>
	</div>
</div>
</body>
</html>